home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
A.C.E. 2
/
ACE CD 2.iso
/
FILES
/
UTILS
/
AMOSPRO5.DMS
/
in.adf
/
Fileo'fax.AMOS
/
Fileo'fax.amosSourceCode
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
AMOS Source Code
|
1992-09-30
|
37.6 KB
|
1,404 lines
' ***************************************************************************
' * *
' * AMOS PROFESSIONAL *
' * ----------------- *
' * *
' * FILOFAX Version 1.1 *
' * *
' * Designed & Written by Stuart Davis. *
' * *
' * Copyright (c) 1992 Europress Software Ltd. *
' * *
' ***************************************************************************
'
'
'
' Filofax internal revision 1.4, last updated on 23rd September, 1992
'
' Program written by Stuart Davis.
'
' Graphics by Stuart Davis.
'
'
' ***************************************************************************
Close Editor
'
' ----------------
' Dimension arrays
' ----------------
'
Dim C0LS(15),BCOORDS(10,2),FD(19,4),KB$(5),WORK$(19),EN$(3),STARDATA(31,1)
Dim _FNAME$(18)
'
' -----------------------
' Define global variables
' -----------------------
'
Global CARDS,CURR_CARD,_MAX_CARDS,CARD_BASE,PNTR_BASE,CANCEL,MBP,CURR_FIELD
Global FILENAME$,MOVE,UNSAVED,FIND$,CURR_PNTR,M$,MEM_RESERVED,STCOUNT
Global STX,STY,STWAIT,RF
'
Global C0LS(),BCOORDS(),FD(),KB$(),WORK$(),EN$(),STARDATA(),_FNAME$()
'
' Variables for screen scrolling for those poor old NTSC Amigas
'
Global CHNGETV_SCROLLSTART,SCRHEIGHT,T,CTV
'
' -----------------------
' Assign global variables
' -----------------------
'
' AMERICAN NTSC addition: Scroll values for screen scrolling
'
CHNGETV_SCROLLSTART=230 : Rem Hardware line at which scrolling starts
SCRHEIGHT=56 : Rem Number of lines to scroll
'
'
'
' Keyboard input strings. Used to make one string of allowable characters.
'
KB$(0)="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
KB$(1)="0123456789"
KB$(2)="( )"
KB$(3)="/"
KB$(4)="."
KB$(5)="!�$%^&*_+|-=\[]{};#:@,/<>?����w'`~"+Chr$(33)
'
EN$(0)="Disc full up!"
EN$(1)="Your disc is write protected."
EN$(2)="There is no disc in the drive"
EN$(3)="An error has occurred!"
'
STCOUNT=23
'
M$="Stop! You have unsaved work. Are your sure you want to proceed?"
'
' Read field names into array for use when printing cards.
'
For COUNT=0 To 18
Read _FNAME$(COUNT)
Next
'
'
'
' Read icon positions. Icon positions are stored in data statements.
' To be really efficient, initially read them into a bank, then access the
' bank (which would be saved with the program).
'
'
For COUNT=O To 10
Read BCOORDS(COUNT,1)
Read BCOORDS(COUNT,2)
Next
'
'--------------------------------------
'
' Initialize Field Data array (storing data on field position, size & type).
'
C=5
For COUNT=1 To 7 : Rem Field data
FD(COUNT,1)=15
FD(COUNT,2)=C
FD(COUNT,3)=30
FD(COUNT,4)=1
Add C,2
Next
'
For COUNT=8 To 19
For INDEX=1 To 4
Read FD(COUNT,INDEX)
Next
Next
'
' Initialize Star Data array (Storing coords for stars)
'
'
For COUNT=0 To 31
Read STARDATA(COUNT,0)
Read STARDATA(COUNT,1)
Next
'
'
' ---------------
' Data statements
' ---------------
'
' Field names
'
Data "SURNAME","FIRST NAMES","STREET","TOWN","CITY","COUNTY","POSTCODE"
Data "D.O.B.","AGE","SEX","COLOUR","WEIGHT","HEIGHT","NATIONALITY","CAR"
Data "PHONE HOME","PHONE WORK","HOBBIES & INTERESTS","COMMENTS"
'
' Icon position data
'
Data 44,225,117,225,171,225,243,225,383,223,383,235,506,228,574,228
Data 305,225,374,228,440,228
'
' Field data (8 to 19)
'
Data 53,5,8,3
Data 69,5,2,5
Data 53,7,6,1
Data 69,7,7,1
Data 53,9,6,2
Data 69,9,5,2
Data 57,11,19,1
Data 53,13,23,1
Data 58,15,18,4
Data 58,17,18,4
Data 23,19,53,1
Data 15,21,61,1
'
'
' Stardata
'
Data 31,214,99,214,167,214,235,214,303,214,371,214,439,214,507,214,575,214
Data 60,230,128,230,196,230,264,230,332,230,400,230,468,230,536,230,604,230
Data 46,180,72,180,133,180,193,180,253,180,314,180,374,180,435,180,495,180
Data 556,180,582,180,541,236,503,4,567,13
'
'
' -------------
' Main routines
' -------------
'
Procedure PREV_CARD
OP_BUT[1,True] : Rem Light button.
Timer=0 : Rem Reset timer.
Gosub GO : Rem Goto previous card.
While Timer<=15 and(Mouse Key>0 or Key State(79)) : Rem Time delay.
Wend
If Timer>=15 : Rem After delay, is mouse key still pressed?
Repeat : Rem Continue to GO while mouse button
Gosub GO : Rem (or key) is pressed.
Until Mouse Key=0 and Not(Key State(79))
End If
OP_BUT[1,False] : Rem Unlight button.
Pop Proc
'
GO:
If CURR_CARD>1
Dec CURR_CARD
DISPLAY_CARD
End If
Return
End Proc
Procedure NXT_CARD
'
' Operation is identical to above procedure.
'
OP_BUT[2,True]
Timer=0
Gosub GO
While Timer<=15 and(Mouse Key>0 or Key State(78))
Wend
If Timer>=15
Repeat
Gosub GO
Until Mouse Key=0 and Not(Key State(78))
End If
OP_BUT[2,False]
Pop Proc
'
GO:
If CURR_CARD<CARDS
Inc CURR_CARD
DISPLAY_CARD
End If
Return
'
End Proc
Procedure FIRST_CARD
OP_BUT[3,True]
WATE_NOMOUSE
If CARDS>0
CURR_CARD=1
DISPLAY_CARD
End If
OP_BUT[3,False]
End Proc
Procedure LAST_CARD
OP_BUT[4,True]
WATE_NOMOUSE
If CARDS>0
CURR_CARD=CARDS
DISPLAY_CARD
End If
OP_BUT[4,False]
End Proc
Procedure NEW_CARD
OP_BUT[9,True]
WATE_NOMOUSE
If Not MEM_RESERVED
RESERVE_MEMORY
End If
'
If CARDS<_MAX_CARDS
Change Mouse 3 : Rem Busy pointer.
Inc CARDS : Rem Increment number of cards in file.
CURR_CARD=CARDS : Rem We are going to edit this new card.
CLR_DISPLAY : Rem Blank this new card.
For COUNT=1 To 19
WORK$(COUNT)=Space$(FD(COUNT,3)) : Rem Initialize our work space.
Next
UDATE_CN : Rem Update the card number.
Change Mouse 1 : Rem Normal pointer.
ED_CARD[False,0] : Rem Edit the card.
_ADD_CARD : Rem Add this to our data structure in
'error - no more cards available
End If
'
'
OP_BUT[9,False]
End Proc
Procedure ED_CARD[EDTING,CURR_FIELD]
Every Off
T=True
Screen Offset 0,0,0
If CARDS>0 : Rem Make sure we have got a card to edit!
UNSAVED=True
Pen 1
Paper 14
While(CURR_FIELD<19 or MOVE<>0) and Not CANCEL
If MOVE=0
Inc CURR_FIELD : Rem edit the next field
Else
Add CURR_FIELD,MOVE : Rem User press up or down arrow so
If CURR_FIELD<1 : Rem act accordingly.
CURR_FIELD=19
Else
If CURR_FIELD>19
CURR_FIELD=1
End If
End If
End If
TYPE=FD(CURR_FIELD,4) : Rem Set some temporary variables.
X=FD(CURR_FIELD,1)
Y=FD(CURR_FIELD,2)
Ink 1
Draw X*8,Y*8+8 To X*8+FD(CURR_FIELD,3)*8,Y*8+8
' Highlight line
'
If TYPE=1 : Rem Text strings (all characters)
RSTRING[WORK$(CURR_FIELD),X,Y,FD(CURR_FIELD,3),%111111]
WORK$(CURR_FIELD)=Param$
Else
If TYPE=2 : Rem Numbers (digits + decimal point)
RSTRING[WORK$(CURR_FIELD),X,Y,FD(CURR_FIELD,3),%10010]
WORK$(CURR_FIELD)=Param$
Else
If TYPE=3
Repeat : Rem Dates (digits and slashes)
RSTRING[WORK$(CURR_FIELD),X,Y,FD(CURR_FIELD,3),%1010]
WORK$(CURR_FIELD)=Param$
_VALID_DATE[Param$] : Rem Check the date is valid
Until Param or(WORK$(CURR_FIELD)="")
Else
If TYPE=4 : Rem Telephone numbers (digits & brackets)
RSTRING[WORK$(CURR_FIELD),X,Y,FD(CURR_FIELD,3),%110]
WORK$(CURR_FIELD)=Param$
Else
' Ages (digits only)
'
RSTRING[WORK$(CURR_FIELD),X,Y,FD(CURR_FIELD,3),%10]
WORK$(CURR_FIELD)=Param$
End If
End If
End If
End If
WORK$(CURR_FIELD)=WORK$(CURR_FIELD)+Space$(FD(CURR_FIELD,3)-Len(WORK$(CURR_FIELD)))
Ink 15
Draw X*8,Y*8+8 To X*8+FD(CURR_FIELD,3)*8,Y*8+8
' Black line
'
If MBP : Rem Mouse button pressed
If Mouse Zone>0
CANCEL=True
Else
MBP=False
MX=X Text(X Screen(X Mouse)) : Rem Get mouse text coords
MY=Y Text(Y Screen(Y Mouse))
IS_IT_A_FIELD[MX,MY] : Rem Is is a field?
If Param>0
CURR_FIELD=Param-1 : Rem Yes, so edit that field
Else
Dec CURR_FIELD : Rem Otherwise, stay on current field -
End If : Rem (dec curr_field as it will be
End If
End If : Rem incremented at the top of the loop).
'
Wend
CANCEL=False
If EDTING
REPLACE_CARD[CURR_CARD]
End If
End If
Every On : Rem FL was ere
End Proc
Procedure S0RT[UP]
OP_BUT[10,True]
If UP
OP_BUT[5,True]
Else
OP_BUT[6,True]
End If
WATE_NOMOUSE
If CARDS>1
'
' Simple "Bubble" sort on pointers in bank 8.
' this sort works best on a data that is "nearly" sorted, so
' it is best to perform a sort regularly.
'
' It would be even better to incorporate an automatic sort every time
' a new card is inserted. This would ensure the filofax remains sorted.
'
Change Mouse 3
Repeat
S0RTED=True
For C=CARDS-1 To 1 Step -1 : Rem Work from the bottom to the top, just like a bubble!
EXTRACT_FIELD[C,1]
If UP
HIGH$=Upper$(Param$)
PHIGH=CURR_PNTR
Else
LOW$=Upper$(Param$)
PLOW=CURR_PNTR
End If
EXTRACT_FIELD[C+1,1]
If UP
LOW$=Upper$(Param$)
PLOW=CURR_PNTR
Else
HIGH$=Upper$(Param$)
PHIGH=CURR_PNTR
End If
If LOW$<HIGH$ : Rem Compare two adjacent cards.
S0RTED=False : Rem Swap if they are not in order.
TMP=Leek(PHIGH)
Loke PHIGH,Leek(PLOW)
Loke PLOW,TMP
End If
Next
Until S0RTED
Change Mouse 1
DISPLAY_CARD
Else
MESSAGE["There are no cards to sort!","OK","OK",False]
End If
OP_BUT[10,False]
OP_BUT[5,False]
OP_BUT[6,False]
End Proc
Procedure FIND
Every Off
OP_BUT[11,True]
WATE_NOMOUSE
If CARDS>0
Get Block 1,24,216,608,37
Ink 15
Bar 46,216 To 599,251 : Rem Draw box
Ink 0
Bar 48,217 To 597,250
Ink 2 : Rem Draw text box.
Bar 268,222 To 516,232
Ink 15
Bar 270,223 To 514,231
'
'
Locate 19,28
Pen 2
Paper 0
Wait Vbl
Print "Text to find"
Pen 1
Paper 15
Locate 34,28
Print FIND$
'
BUTTON[False,60,234,80,12,"OK"] : Rem Draw buttons
BUTTON[False,268,234,112,12,"Find Previous"]
BUTTON[False,400,234,112,12,"Find Next"]
Set Zone 1,60,234 To 140,246
Set Zone 2,268,234 To 380,246
Set Zone 3,400,234 To 512,246
Set Zone 4,268,222 To 516,232
'
Repeat
If MBP : Rem Deal with "Superactivity"
MBP=False
Else
Repeat : Rem Wait for mouse click.
Multi Wait
Until Mouse Click
End If
MBOX=Mouse Zone
If MBOX=1
BUTTON[True,60,234,80,12,"OK"]
OK=True
Else
If MBOX=2
BUTTON[True,268,234,112,12,"Find Previous"]
If CURR_CARD>1
WATE_NOMOUSE
Change Mouse 3
For COUNT=CURR_CARD-1 To 1 Step -1 : Rem look at previous cards.
For F=1 To 19
EXTRACT_FIELD[COUNT,F] : Rem Extract next surname.
NOSPACE[Param$]
If Instr(Param$,FIND$)
CURR_CARD=COUNT : Rem Go to matching card.
EXTRACT_CARD[CURR_CARD] : Rem Retreive that card...
DISPLAY_CARD : Rem and display it.
Exit 2 : Rem Slap Wrists! - A Repeat ... Until loop would
End If : Rem have been more structured, but this is an
Next : Rem example of the exit command!
Next
If COUNT=0
Bell : Rem There are no more matching cards.
End If
Else
Bell : Rem We are already at the first card.
End If
Change Mouse 1
BUTTON[False,268,234,112,12,"Find Previous"]
Else
If MBOX=3
BUTTON[True,400,234,112,12,"Find Next"] : Rem this section is
If CURR_CARD<CARDS : Rem identical to that above.
WATE_NOMOUSE
Change Mouse 3
For COUNT=CURR_CARD+1 To CARDS
For F=1 To 19
EXTRACT_FIELD[COUNT,F]
NOSPACE[Param$]
If Instr(Param$,FIND$)
CURR_CARD=COUNT
EXTRACT_CARD[CURR_CARD]
DISPLAY_CARD
Exit 2
End If
Next
Next
If COUNT>CARDS
Bell
End If
Else
Bell
End If
Change Mouse 1
BUTTON[False,400,234,112,12,"Find Next"]
Else
If MBOX=4
Pen 1
Paper 15
RSTRING[FIND$,34,28,30,%111111]
FIND$=Param$
End If
End If
End If
End If
Until OK
'
Else
MESSAGE["There is nothing to find!","OK","OK",False]
End If
WATE_NOMOUSE
ICON_ZONES
Put Block 1
OP_BUT[11,False]
'
End Proc
Procedure EXTRACT_FIELD[CARD_NO,F]
CURR_PNTR=((CARD_NO-1)*4)+PNTR_BASE : Rem Calculate pointers.
CURR_BASE=Leek(CURR_PNTR)+CARD_BASE
If F>1
For L=2 To F
Add OFFSET,FD(L,3) : Rem Calculate offset to required field.
Next
End If
RESULT$=Space$(FD(F,3)) : Rem Assign space for the required info.
Areg(0)=CURR_BASE+OFFSET : Rem The start of the surname on the card.
Areg(1)=Varptr(RESULT$) : Rem Start of our storage space.
Dreg(0)=30 : Rem Length of memory to copy.
R=Execall(-624) : Rem Copy the memory into our storage space.
End Proc[RESULT$]
Procedure DISPLAY_CARD
EXTRACT_CARD[CURR_CARD] : Rem Get the current card from the
Pen 1 : Rem bank and put it in WORK$()
Paper 14
For COUNT=1 To 19
Locate FD(COUNT,1),FD(COUNT,2)
Print WORK$(COUNT)
Next
UDATE_CN
End Proc
Procedure RESERVE_MEMORY
On Error Proc HANDLE_ERROR
Resume Label RECOVER
Change Mouse 3
AVAILMEM[0] : Rem Get the largest block of memory.
_MAX_CARDS=Min(400,(Param-436)/436) : Rem 400 is the maximum number we want.
Reserve As Work 6,436*_MAX_CARDS : Rem Reserve bank 6 for data
CARD_BASE=Start(6)+4
Reserve As Work 8,(_MAX_CARDS*4) : Rem Reserve bank 8 for pointers
PNTR_BASE=Start(8)
MEM_RESERVED=True
RECOVER:
Change Mouse 1
End Proc
Procedure _ADD_CARD
'
' Add a new card to the data structure in bank 6
'
CURR_BASE=(CURR_CARD-1)*436+CARD_BASE : Rem Calculate pointers
CURR_PNTR=((CURR_CARD-1)*4)+PNTR_BASE
Loke CURR_PNTR,CURR_BASE-CARD_BASE : Rem Set the pointer
'
_FIELD_OFFSET=0
For COUNT=1 To 19 : Rem Loop for each field
Areg(0)=Varptr(WORK$(COUNT)) : Rem Start of memory to be moved.
Areg(1)=CURR_BASE+_FIELD_OFFSET : Rem Start of destination.
Dreg(0)=Len(WORK$(COUNT)) : Rem Length of memory to be moved.
R=Execall(-624) : Rem exec library COPY MEM function.
Add _FIELD_OFFSET,FD(COUNT,3) : Rem Start of next field.
Next
End Proc
Procedure REPLACE_CARD[CARD_NO]
'
' Return the current card to bank 6 in its correct position.
'
CURR_PNTR=((CARD_NO-1)*4)+PNTR_BASE : Rem Calculate pointers.
CURR_BASE=Leek(CURR_PNTR)+CARD_BASE
_FIELD_OFFSET=0
For COUNT=1 To 19
Areg(0)=Varptr(WORK$(COUNT)) : Rem Registers described in above procedure.
Areg(1)=CURR_BASE+_FIELD_OFFSET
Dreg(0)=Len(WORK$(COUNT))
R=Execall(-624) : Rem exec library COPY MEM function.
Add _FIELD_OFFSET,FD(COUNT,3)
Next
End Proc
Procedure EXTRACT_CARD[CARD_NO]
'
' Reverse operation of above procedure.
'
CURR_PNTR=((CARD_NO-1)*4)+PNTR_BASE
CURR_BASE=Leek(CURR_PNTR)+CARD_BASE
_FIELD_OFFSET=0
For COUNT=1 To 19
WORK$(COUNT)=Space$(FD(COUNT,3))
Areg(0)=CURR_BASE+_FIELD_OFFSET
Areg(1)=Varptr(WORK$(COUNT))
Dreg(0)=FD(COUNT,3)
R=Execall(-624)
Add _FIELD_OFFSET,FD(COUNT,3)
Next
End Proc
Procedure DEL_CARD
If CARDS>0
MESSAGE["Discard this card?","Discard","NO!",True]
If Param
If CARDS=1
CLEAR
Else
CURR_PNTR=((CURR_CARD-1)*4)+PNTR_BASE
CURR_BASE=Leek(CURR_PNTR)+CARD_BASE
Areg(0)=CURR_BASE+436
Areg(1)=CURR_BASE
Dreg(0)=CARD_BASE+(CARDS*436)-CURR_BASE
R=Execall(-624)
Areg(0)=CURR_PNTR+4
Areg(1)=CURR_PNTR
Dreg(0)=PNTR_BASE+(CARDS*4)-PNTR_BASE
R=Execall(-624)
Dec CARDS
CURR_CARD=Min(CARDS,CURR_CARD)
For CDS=1 To CARDS
CURR_PNTR=((CDS-1)*4)+PNTR_BASE
If Leek(CURR_PNTR)>CURR_BASE-CARD_BASE
Loke CURR_PNTR,Leek(CURR_PNTR)-436
End If
Next
End If
End If
If CARDS>0
DISPLAY_CARD
End If
Else
MESSAGE["You have no cards!","OK","OK",False]
End If
End Proc
Procedure CLEAR_CARDS
If CARDS>0
If UNSAVED
MESSAGE[M$,"Yes","No",True]
Else
MESSAGE["Clear all cards.","Proceed","Cancel",False]
End If
If Param
CLEAR
End If
Else
MESSAGE["You cave no cards to clear!","OK","OK",False]
End If
End Proc
Procedure PCARD[ALL]
On Error Goto SMEG
If CARDS>0 : Rem Only print if there is something to print!
Change Mouse 3 : Rem Busy mouse
Open Port 1,"PRT:" : Rem Open printer driver driven printer
If ALL : Rem If ALL cards are to be printed...
FIRST=1
LAST=CARDS
Else
FIRST=CURR_CARD
LAST=CURR_CARD
End If
Print #1,String$("-",80) : Rem Line of dotted lines
For COUNT=FIRST To LAST
X$=Inkey$
If X$=Chr$(27) : Rem Test for escape key and abort printing
Bell : Rem if pressed.
Exit
End If
EXTRACT_CARD[COUNT] : Rem get card to be printed.
BOLD_ON
Print #1,"CARD NUMBER";COUNT : Rem Print the card number of card being printed
BOLD_OFF
Print #1,String$("-",80)
OFFSET=7 : Rem Offset to next field to be printed on
For L=0 To 6 : Rem this line
X$=Inkey$
If X$=Chr$(27) : Rem Another test for escape key
Bell
Exit 2
End If
'
' Left field column
'
BOLD_ON
Print #1,Space$(11-Len(_FNAME$(L)))+_FNAME$(L);
BOLD_OFF
Print #1," "+WORK$(L+1);
'
' Right field column
'
BOLD_ON
Print #1,Space$(12-Len(_FNAME$(L+OFFSET)))+_FNAME$(L+OFFSET);
BOLD_OFF
Print #1," "+WORK$(L+1+OFFSET);
'
' Farthest right field column (AGE, COLOUR, HEIGHT)
'
If L+OFFSET<=12
If L+OFFSET+1=10 or L+OFFSET+1=12
Print #1," ";
End If
BOLD_ON
Print #1,Space$(9-Len(_FNAME$(L+OFFSET+1)))+_FNAME$(L+OFFSET+1);
BOLD_OFF
Print #1," "+WORK$(L+2+OFFSET)
Inc OFFSET
Else
Print #1,Chr$(13)
End If
Print #1,Chr$(13)
Next
'
' Last 2 fields
'
BOLD_ON
Print #1,_FNAME$(17);
BOLD_OFF
Print #1," "+WORK$(18)
Print #1,Chr$(13)
BOLD_ON
Print #1,_FNAME$(18);
BOLD_OFF
Print #1," "+WORK$(19)
BOLD_OFF
Print #1,String$("-",80)
Next
Close 1
ER:
EXTRACT_CARD[CURR_CARD] : Rem Restore WORKS$ to card that is being
Change Mouse 1 : Rem displayed.
Else
MESSAGE["There is nothing to print!","Whoops!","Whoops!",False]
End If
Pop Proc
'
SMEG:
MESSAGE["I/O ERROR! Check printer & cables","OK","OK",True]
Close
Resume ER
End Proc
Procedure BOLD_ON
Print #1,Chr$(27);"[1m";
End Proc
Procedure BOLD_OFF
Print #1,Chr$(27);"[22m";
End Proc
Procedure CLEAR
'
' Initilize variables
'
CURR_CARD=0
CARDS=0
_MAX_CARDS=0
MEM_RESERVED=False
CLR_DISPLAY
Erase 6
Erase 8
End Proc
'
' ---------------
' Filing routines
' ---------------
'
Procedure RMOVE_EXT[WORD$]
'
' Remove the . extension from passed string.
'
If Right$(WORD$,4)=".FLX" or(Right$(WORD$,4)=".FNX")
WORD$=Left$(WORD$,(Len(WORD$)-4))
End If
End Proc[WORD$]
Procedure NAME_FROM_PATH[P$]
'
' Return the file name from the path name
'
F$=Right$(P$,(Len(P$)-(Instr(P$,":"))))
If Instr(F$,"/")
X=Len(F$)
Repeat
Dec X
Until Mid$(F$,X,1)="/"
F$=Right$(F$,Len(F$)-X)
End If
End Proc[F$]
Procedure _LOAD
On Error Proc HANDLE_ERROR
Resume Label RECOVER
OP_BUT[7,True]
WATE_NOMOUSE
GO=True
'
If UNSAVED
MESSAGE[M$,"Yes","No",True]
GO=Param
End If
If GO
' Get the filename to load.
T=True
Screen Offset 0,0,0
FILENAME$=Fsel$(Dir$+"*.FNX","","Load a","FILE O' FACTS file")
If FILENAME$<>"" : Rem Only load if filename given.
Change Mouse 3
RMOVE_EXT[FILENAME$]
CLEAR : Rem We are loading a new card file, so
F$=Param$+".FLX"+Chr$(0) : Rem clear the old one out.
Dreg(1)=Varptr(F$) : Rem OPEN file
Dreg(2)=1005 : Rem for READING
FILE_HANDLE=Doscall(-30) : Rem Pointer to dos file handle
If FILE_HANDLE>0 : Rem If file was opened successfully...
'
' Read the number of cards in the file
'
Dreg(1)=FILE_HANDLE
Dreg(2)=Varptr(CARDS) : Rem Put value read into variable cards
Dreg(3)=4 : Rem We want to read first FOUR bytes
AMOUNT_READ=Doscall(-42) : Rem Do the read
If AMOUNT_READ=4 : Rem Make sure everything was all right
RESERVE_MEMORY
If _MAX_CARDS>=CARDS : Rem Then we have room to load the file
Dreg(1)=FILE_HANDLE
Dreg(2)=Start(6)+4
Dreg(3)=CARDS*436 : Rem Read rest of file into bank 6.
AMOUNT_READ=Doscall(-42) : Rem Do the read
NF$=Param$+".FNX"
If Exist(NF$)
Bload NF$,Start(8) : Rem load the index file (pointers).
End If
CURR_CARD=1 : Rem Initialize then display first card.
DISPLAY_CARD
UNSAVED=False
Else
MESSAGE["There is not enough memory to load your file.","OK","OK",False]
CLEAR: Rem Not enough memory, so keep cleared!
End If
End If
Dreg(1)=FILE_HANDLE : Rem CLOSE the file
FILE_HANDLE=Doscall(-36)
Else
'error: No file handle - couldn't open file.
MESSAGE["Could not open file.","Continue","Continue",False]
End If
RECOVER:
Change Mouse 1
End If
End If
OP_BUT[7,False]
End Proc
Procedure _SAVE
On Error Proc HANDLE_ERROR
Resume Label RECOVER
OP_BUT[8,True]
WATE_NOMOUSE
If CARDS>0 : Rem Only proceed if we have at least one card
Loke Start(6),CARDS : Rem Store the number of cards at the start
' of the bank.
NAME_FROM_PATH[FILENAME$]
T=True
Screen Offset 0,0,0
F$=Fsel$(Dir$+"*.FNX",Param$,"Save your","FILE O' FACTS file")
If F$<>""
FILENAME$=F$
RMOVE_EXT[FILENAME$]
Change Mouse 3
F$=Param$+".FLX"
' Save our cards in bank 6 and our pointers
' in bank 8.
'
' Note that pointers and data could be in
' the same bank, but it is easier to
' handle them seperatly to show their use.
'
Bsave F$,Start(6) To Start(6)+4+(436*CARDS)
F$=Param$+".FNX"
Bsave F$,Start(8) To Start(8)+(4*CARDS)
UNSAVED=False
End If
Else
MESSAGE["There are no cards to save!","OK","OK",False]
End If
RECOVER:
OP_BUT[8,False]
Change Mouse 1
End Proc
'
' ----------------
' Service routines
' ----------------
'
Procedure _VALID_DATE[DATE$]
'
' Check that the date passed in DATE$ is valid.
'
VD=((Mid$(DATE$,3,1)="/") and(Mid$(DATE$,6,1)="/"))
If VD
DAY=Val(Left$(DATE$,2))
MONTH=Val(Mid$(DATE$,4,2))
YEAR=Val(Right$(DATE$,2))
VD[DAY,MONTH,YEAR]
VD=Param
End If
End Proc[VD]
Procedure VD[DAY,MONTH,YEAR]
'
' Check that DAY MONTH and YEAR are valid.
'
_VALID_DAY[DAY,MONTH]
VD=Param
LEAP_YEAR[YEAR]
LP=Param
If DAY=29 and MONTH=2 and LP
VD=True
End If
End Proc[VD]
Procedure LEAP_YEAR[YEAR]
'
' Is the YEAR a leap year?
'
LP=(YEAR mod 4=0) or(YEAR mod 1000=0)
End Proc[LP]
Procedure _VALID_DAY[DAY,MONTH]
'
' Check the day is within the number of days in the month
'
DAYS_IN_MONTH[MONTH]
VD=(DAY>0) and(DAY<=Param)
End Proc[VD]
Procedure DAYS_IN_MONTH[MONTH]
'
' Return the number of days in the requested month
'
D=0
MONTH$=Str$(MONTH)
If Instr(" 1 3 5 7 8 10 12",MONTH$)
D=31
Else
If Instr(" 4 6 9 11",MONTH$)
D=30
Else
If MONTH=2
D=28
End If
End If
End If
End Proc[D]
Procedure NOSPACE[TXT$]
'
' Remove spaces from the end of the passed string.
'
While Right$(TXT$,1)=" "
TXT$=Left$(TXT$,Len(TXT$)-1)
Wend
End Proc[TXT$]
Procedure RSTRING[TXT$,XPOS,YPOS,LMAX,AK]
'
' Read user input into a string.
' TXT$ contains default starting string.
' XPOS & YPOS are the X and Y text positions for the first character
' LMAX in the maximum length of the string
' AK is a flag to indicate the allowable keys.
'
WATE_NOMOUSE
Clear Key
NOSPACE[TXT$]
TXT$=Param$
MOVE=0
CHAR$=""
For COUNT=0 To 5
If Btst(COUNT,AK)
CHAR$=CHAR$+KB$(COUNT)
End If
Next
TEMP_INS=1 : Rem 1=Insert, 2=Overwrite
CANCEL=False
X=Len(TXT$)
Repeat
Curs Off
Locate XPOS,YPOS
Print TXT$;
' Locate 0,0 : Print X,XPOS+LMAX
If X+XPOS<XPOS+LMAX
Print " ";
End If
Locate XPOS+X,YPOS
Curs On
Repeat
MK=Mouse Key
KY$=Inkey$
KY=Scancode
Until KY$<>"" or(MK=1)
If KY=65 and X>0
TXT$=Left$(TXT$,X-1)+Mid$(TXT$,X+1)
X=Max(0,X-1)
End If
If KY=70
TXT$=Left$(TXT$,X)+Mid$(TXT$,X+2)
KY=-1
End If
If KY=79
X=Max(0,X-1)
KY=-1
End If
If KY=78
X=Min(Len(TXT$),X+1)
KY=-1
End If
If Instr(CHAR$,KY$) and KY>0
If X<LMAX
TXT$=Left$(TXT$,X)+KY$+Mid$(TXT$,X+TEMP_INS)
If Len(TXT$)>LMAX
TXT$=Left$(TXT$,LMAX)
End If
X=Min(LMAX,X+1)
End If
End If
Until(KY$=Chr$(13)) or(KY$=Chr$(27)) or(KY$=Chr$(30)) or(KY$=Chr$(31)) or(MK=1)
If KY$=Chr$(27)
CANCEL=True
End If
If KY$=Chr$(30)
MOVE=-1
End If
If KY$=Chr$(31)
MOVE=1
End If
MBP=(MK=1)
Curs Off
End Proc[TXT$]
Procedure IS_IT_A_FIELD[X,Y]
'
' Is there a field at text positions XY. If so, return the field number.
'
FOUND=False
RT=0
For FP=1 To 19
If FD(FP,2)=Y
If X>=FD(FP,1) and(X<=(FD(FP,1))+FD(FP,3))
FOUND=True
RT=FP
Exit
End If
End If
Next
If Not FOUND Then RT=0
End Proc[RT]
Procedure MESSAGE[TXT$,BUT1$,BUT2$,WARN]
Every Off
Change Mouse 1
WATE_NOMOUSE
Get Block 1,24,216,608,37
If WARN
Ink 9
Else
Ink 15
End If
Bar 46,216 To 599,251 : Rem Draw box
Ink 0
Bar 48,217 To 597,250
Ink 1,0
Text 320-(Len(TXT$)*4),227,TXT$
BUTTON[False,60,234,80,12,BUT1$]
BUTTON[False,499,234,80,12,BUT2$]
Set Zone 1,60,234 To 140,246
Set Zone 2,499,234 To 579,246
Wait 50
Repeat
Repeat
Multi Wait
Until Mouse Click=1 or Key Shift=64 or Key Shift=128
If Key Shift=128
MBOX=2
Else
If Key Shift=64
MBOX=1
Else
MBOX=Mouse Zone
End If
End If
If MBOX=1
BUTTON[True,60,234,80,12,BUT1$]
RESULT=True
Else
If MBOX=2
BUTTON[True,499,234,80,12,BUT2$]
RESULT=False
End If
End If
Until MBOX=1 or MBOX=2
WATE_NOMOUSE
Repeat
Until Key Shift=0
ICON_ZONES
Put Block 1
End Proc[RESULT]
Procedure WATE_NOMOUSE
While Mouse Key<>0
Wend
End Proc
Procedure AVAILMEM[X]
'
'Load D1 WITH 0 For ALL MEM,2 For CHIP MEM and 4 For FAST MEM
'
Dreg(1)=X+131072 : Rem 2^17 - set bit 17 to receive max block available
RESULT=Execall(-216) : Rem call exec library AVAILMEM function
End Proc[RESULT]
Procedure HANDLE_ERROR
If Errn=88
EN=0
Else
If Errn=84
EN=1
Else
If Errn=93
EN=2
Else
EN=3
End If
End If
End If
MESSAGE[EN$(EN),"OK","OK",True]
Resume Label
End Proc
Procedure DUMMY
End Proc
'
' ----------------
' Display routines
' ----------------
'
Procedure BUTTON[LIT,X,Y,W,H,T$]
Ink 0
Bar X,Y To X+W+2,Y+H+1
Ink 13
Bar X+4,Y+2 To X+4+W,Y+H+2 : Rem Shadow
If LIT
Add X,2
Inc Y
End If
Ink 15
Bar X,Y To X+W,Y+H : Rem Black box
Ink 5
Bar X+2,Y+1 To X+W-2,Y+H-1 : Rem Grey inside
If LIT
Ink 12,5
Else
Ink 11,5
End If
Text X+(W/2)-(Len(T$)*4),Y+9,T$
End Proc
Procedure UDATE_CN
Ink 1,13
If CARDS=0
N$=" "
Else
N$=Str$(CURR_CARD)-" "
N$=String$("0",3-Len(N$))+N$
End If
Text 206,24,N$
End Proc
Procedure ICON_ZONES
'
' Reserve the zones for the icons at bottom of screen
'
For COUNT=1 To 9
Set Zone COUNT-((COUNT>6)),(67*COUNT)-35,220 To(67*COUNT)+7,240
Next
Set Zone 6,370,220 To 407,229
Set Zone 7,370,230 To 407,240
Set Zone 11,548,242 To 564,250
End Proc
Procedure STAR
If STWAIT<1 : Rem Time delay between flashes
If STCOUNT=34 : Rem Reset star icons to start again
STCOUNT=23
End If
'
If STCOUNT=23 : Rem We've come full circle so choose new
RF=Rnd(70) : Rem Random time between flashes
ST=Rnd(31) : Rem flash position.
STX=STARDATA(ST,0)
STY=STARDATA(ST,1)
Get Block 2,STX,STY,16,14 : Rem Block to restore screen as it is
End If : Rem uncovered.
'
If STCOUNT<29 : Rem Paste icon neat.
Paste Icon STX,STY,STCOUNT
Else
Put Block 2
Paste Icon STX,STY,STCOUNT-((STCOUNT-28)*2) : Rem going backwards from
End If : Rem big star to small star
Inc STCOUNT : Rem Number of star frames
Else
Inc STWAIT : Rem Increment wait between stars counter
End If
If STCOUNT=34 : Rem remove last frame
Inc STWAIT
Put Block 2
End If
If STWAIT>=RF : Rem Reset after random delay time
STWAIT=0
End If
'
Every On
End Proc
Procedure OP_BUT[BUT,LIT]
'
' Illuminate the buttons. BUT is button to affect, LIT = true to light it.
'
C=BUT-1
If BUT<9
BUT=BUT-(LIT=False)*8 : Rem Get right icon (alight or dark)
Else
BUT=8+BUT-(LIT=False)*3
End If
'
Paste Icon BCOORDS(C,1),BCOORDS(C,2),BUT
'
'
End Proc
Procedure FAD_ALL[W]
For T=1 To W
Colour Back(Colour(0))
View
Wait Vbl
Next
End Proc
Procedure RESET_MOUSE_AREA
Limit Mouse 128,39 To 447,291
End Proc
Procedure INIT_DISPLAY
Auto View Off : Rem Prevent Amos from turning screen on!
Hide
Screen Open 0,640,256,16,Hires : Rem Open a 16 colour medium res screen
Screen Hide 0 : Rem Make the screen go blank while it is set up.
Unpack 5 To 0 : Rem Restore packed screen from bank 5
Flash Off
Curs Off
Set Curs 192,192,192,192,192,192,192,192 : Rem Describe cursor bit pattern (shape)
For COUNT=0 To 15
C0LS(COUNT)=Colour(COUNT) : Rem Record colours in array C0LS
Next
Palette 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 : Rem Set palette to black before fade
Colour Back Colour(0)
Screen Display 0,,37,,
RESET_MOUSE_AREA
If CTV
Screen Display 0,140,37,640,200
End If
Auto View On : Rem Turn screen on.
Screen 0
Screen Show 0
' Smooth fades, courtesy Mr. Amos!
Fade 2,$48A : Rem First the background.
FAD_ALL[32] : Rem Ensure border is faded too.
Wait 3
Fade 3,,,,,,,,,,$FF0 : Rem Next the power light comes on.
Wait 30
Fade 3,,,,,,,,,,$F00 : Rem Next the power light comes on.
Wait 25
' And finally, everything is lit!
Fade 2,C0LS(0),C0LS(1),C0LS(2),C0LS(3),C0LS(4),C0LS(5),C0LS(6),C0LS(7),C0LS(8),C0LS(9),C0LS(10),C0LS(11),C0LS(12),C0LS(13),C0LS(14),C0LS(15)
Show
Wait 10
End Proc
Procedure CLR_DISPLAY
Paper 14
For COUNT=1 To 19
Locate FD(COUNT,1),FD(COUNT,2)
Print Space$(FD(COUNT,3))
Next
UDATE_CN
End Proc
'
' ------------
' Main program
' ------------
'
CTV=Ntsc
INIT_DISPLAY
Reserve Zone 11
ICON_ZONES
Request Off
Make Icon Mask : Rem All icons have colour 0 transparent.
Get Block 2,0,0,16,1 : Rem Initial block for stars.
Every 3 Proc STAR : Rem every 3/50ths of a sec update the
' flashing star highlight
T=True
Screen Offset 0,0,0
Repeat
Every On
If MBP : Rem Drop through loop if mouse button pressed
MBP=False
Else
Repeat : Rem Wait for the left mouse button.
K$=Inkey$
'
' AMERICAN NTSC bodge fix to scroll control panel into view
'
If CTV
If Y Mouse>CHNGETV_SCROLLSTART and T
T=False
For COUNT=0 To SCRHEIGHT Step 14
Wait Vbl
Screen Offset 0,,COUNT
Next
Y Mouse=CHNGETV_SCROLLSTART-SCRHEIGHT+10
End If
If Y Mouse<CHNGETV_SCROLLSTART-SCRHEIGHT and Not T
T=True
For COUNT=SCRHEIGHT To 0 Step -14
Wait Vbl
Screen Offset 0,,COUNT
Next
Y Mouse=CHNGETV_SCROLLSTART-10
End If
End If
'
Until Mouse Click=1 or(K$<>"")
End If
Every Off
MBOX=0 : Rem Handle keyboard input:
If K$<>""
If K$="d" and Key Shift=128
DEL_CARD
Else
If K$="c" and Key Shift=128
Bell
CLEAR_CARDS
Else
If K$="p"
If Key Shift=128
PCARD[False]
Else
If Key Shift=8
PCARD[True]
End If
End If
Else
If K$=Chr$(29) and Key Shift=8
MBOX=3
Else
If K$=Chr$(28) and Key Shift=8
MBOX=4
Else
If K$=Chr$(29)
MBOX=1
Else
If K$=Chr$(28)
MBOX=2
Else
If K$="n"
MBOX=5
Else
If K$="l" and Key Shift=128
MBOX=9
Else
If K$="s" and Key Shift=128
MBOX=10
Else
If K$="q" and Key Shift=128
MBOX=11
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Else
MBOX=Mouse Zone
End If
Clear Key
If MBOX>0
On MBOX Proc PREV_CARD,NXT_CARD,FIRST_CARD,LAST_CARD,NEW_CARD,DUMMY,DUMMY,FIND,_LOAD,_SAVE
If MBOX>=6 and MBOX<=7
S0RT[MBOX-7]
End If
If MBOX=11
If UNSAVED
MESSAGE[M$,"Yes","No",True]
Else
MESSAGE["Quit File O' Facts. Are you sure?","Yes","No way",True]
End If
QUIT=Param
End If
Else
If K$=""
MX=X Text(X Screen(X Mouse))
MY=Y Text(Y Screen(Y Mouse))
IS_IT_A_FIELD[MX,MY]
If Param>0
ED_CARD[True,Param-1]
End If
End If
End If
K$=""
Until QUIT
Every Off
Fade 3,,,,,,,,,,0 : Rem Turn off power light.
Wait 40
' fade to blue
Fade 2,1162,1162,1162,1162,1162,1162,1162,1162,1162,1162,1162,1162,1162,1162,1162,1162
Wait 40
Fade 2 : Rem Fade to black
FAD_ALL[40]
Edit